import request from "@/utils/http/request";

// 获取用户数据
export const reqUserList = ({ page, limit, username, nickName }: any) => {
  return request.get<any, any>("/admin/acl/user/" + `${page}/${limit}`, {
    params: {
      username,
      nickName,
    },
  });
};

// 添加用户或修改用户
export const reqAddOrUpdateUser = (data: any) => {
  if (data.id) {
    return request.put<any, any>("/admin/acl/user/update", data);
  } else {
    return request.post<any, any>("/admin/acl/user/save", data);
  }
};

// 删除用户
export const reqDeleteUser = (id: any) => {
  return request.delete<any, any>("/admin/acl/user/remove/" + id);
};

// 获取角色数据
export const reqAssignData = (userId: any) => {
  return request.get<any, any>("/admin/acl/user/toAssign/" + userId);
};

// 给用户添加角色
export const reqAddAssign = (userId: any, roleId: any) => {
  return request.post(
    "/admin/acl/user/doAssign",
    {},
    {
      params: {
        userId,
        roleId,
      },
    }
  );
};
